// pages/home-video/index.js
import {
  getTopMv
} from '../../service/video-api'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    topmv: [],
    hasMore:true
  },
  handlevideoitemcleck(event) {
    // console.log("item",event)
    const id = event.currentTarget.dataset.item.id
    wx.navigateTo({
      url: '/pages/video-music/index?id='+id,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    getTopMv(0).then(res => {
      console.log(res)
      this.setData({topmv : res.data})
    })
  },
  onReachBottom:async function () {
    if (!this.data.hasMore) return
    const res = await getTopMv(this.data.topmv.length)
    this.setData({topmv:this.data.topmv.concat(res.data)})
    console.log(this.data)
    this.setData({hasMore:this.data.hasMore})
  },
  onPullDownRefresh:async function (){
    getTopMv(0).then(res => {
      console.log(res)
      this.setData({topmv : res.data})
    })
  }

})